/**
 * 首页
 */
const app = getApp();

Page({
    data: {
        pageLoading: false,
        navBarHeight: app.globalData.navBarHeight,
        menuRight: app.globalData.menuRight,
        menuTop: app.globalData.menuTop,
        menuHeight: app.globalData.menuHeight,
        sortActive: 1,
        isShow: "",
        activeSort:"1",
    },
    onLoad() {

        // // loading
        // app.utils.loading.show();
        // setTimeout(() => {
        //     app.utils.loading.hide();
        // }, 1000)

        // // 接口调用
        // app.api.testApi.test().then(() => { })

    },
    onChange(event) {
        wx.showToast({
            title: `切换到标签 ${event.detail.name}`,
            icon: 'none',
        });
    },
    getUserInfo: e => {


        wx.login({
            success: function (res) {
                let code = res.code // 登录凭证code\
                console.log("code", code)
                if (code) {
                    wx.request({
                        url: 'https://mis-test.weilian.city/city/member/login',
                        method: 'POST',
                        data: {
                            code: code //登录凭证code
                        },
                        header: {
                            'content-type': 'application/json;charset=UTF-8'
                        },

                        success: function (res) {
                            // var userphone = res.data.data
                            // //解密手机号
                            // var msg = e.detail.errMsg;
                            // var sessionKey = userphone.session_key; //会话密钥
                            // var encryptedData = e.detail.encryptedData; //签名
                            // var unionid = userphone.unionid //唯一标识
                            // var iv = e.detail.iv;
                          console.log('res',res.data)
                        }
                    })
                }




            }
        })

    },
    activeBtn(e){
      this.setData({
        activeSort:e.target.dataset.active
      })
     
    },

    handleClick() {
        // 表单校验
        let form = {
            tel: '1383435346'
        }
        let rules = {
            tel: [{
                    required: true,
                    message: '年龄不能为空'
                },
                {
                    pattern: /^1[3456789]\d{9}$/,
                    message: '请输入正确的手机号码'
                },
            ]
        }

        app.validator(rules, form).then(() => {

            // 校验成功
            console.log('校验成功')
        })
    }
})
